<%= form_for(@wallet) do |f| %>
  <% if @wallet.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@wallet.errors.count, "error") %> prohibited this wallet from being saved:</h2>

      <ul>
      <% @wallet.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <table>
    <tr>
      <td><%= f.label :name %></td>
      <td><%= f.text_field :name %></td>
    </tr>

    <tr>
      <td valign="top">Amounts</td>
      <td>
        <table class="amounts">
          <thead>
            <tr>
              <th></th>
              <th></th>
              <th></th>
            </tr>
          </thead>

          <%= f.fields_for :amounts do |builder| %>
              <tr class="amount" style="padding-left:30px;">
                <td><%= builder.text_field :value %></td>
                <td><%= builder.collection_select :currency_id, Currency.all, :code, :code %></td>
                <td><%= builder.hidden_field :_destroy%><%= link_to_function "remove", "removeAmount(this)"%></td>
              </tr>
          <% end %>

          <%= f.fields_for :amounts, Amount.new, :child_index => "new_amount" do |builder| %>
              <tr class="template" style="padding-left:30px; display:none">
                <td><%= builder.text_field :value %></td>
                <td><%= builder.collection_select :currency_id, Currency.all, :code, :code %></td>
                <td><%= builder.hidden_field :_destroy%><%= link_to_function "remove", "removeAmount(this)"%></td>
              </tr>
          <% end %>
        </table>
        
        <%= link_to_function "add", "addAmount()" %>
      </td>
    </tr>
  </table>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
